<?php
namespace app\admin\controller;

use think\Controller;
use think\Request;
use app\common\model\Admin;
use think\Session;

class Login extends Controller {

    public function index(){
        return view('');
    }

    public function login(Request $request){
        $username = $request->post("username");
        $password = $request->post("password");
        $admin = new Admin();
        $res = $admin ->login($username,$password);

        if(!$res['state']){
            $this->success("登录成功",url('admin/index/index'));
        }
        $this->error("登录失败",url('admin/login/index'));
    }

    public function logout(){
        Session::delete('admin');
        $this->success("成功退出系统",url('admin/login/index'));
    }

}